package com.common.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

/**
 * @Author: zql
 * @Description: 通用配置项
 * @Data: 16:18 2021/4/30
 */

@Component
@ConfigurationProperties(prefix = "config")
public class Config {

    /** 本地资源绝对路径 */
    private static String localFilePath;

    /** 设备指纹 */
    private static String Fingerprint;

    /** 接口授权校验 */
    private static boolean verifyLogin;

    private static String key;
    /**aes加解密模块 密钥*/
    @Value("${config.aesKey:zhongrui_aes.com}")
    public void setKey(String key){
        Config.key=key;
    }

    public static String getKey(){
        return key;
    }

    private static boolean flag;
    /**aes开关*/
    @Value("${config.aesFlag:false}")
    public void setFlag(boolean flag){
        Config.flag=flag;
    }

    public static boolean isFlag(){
        return flag;
    }

    public static boolean isVerifyLogin() {
        return verifyLogin;
    }
    /**登录授权校验*/
    @Value("${config.verifyLogin:true}")
    public void setVerifyLogin(boolean verifyLogin) {
        Config.verifyLogin = verifyLogin;
    }

    public static String getLocalFilePath() {
        return localFilePath;
    }
    /**文件资源路径 */
    @Value("${config.profile:/uploadPath}")
    public void setProfile(String profile) {
        Config.localFilePath = System.getProperty("user.dir")+profile;
    }

    public static String getFingerprint() {
        return Fingerprint;
    }
    /**设备指纹请求头*/
    @Value("${config.Fingerprint:Fingerprint}")
    public  void setFingerprint(String fingerprint) {
        Fingerprint = fingerprint;
    }

    /**
     * 获取下载路径
     */
    public static String getDownloadPath()
    {
        return getLocalFilePath() + "/download/";
    }

    /**
     * 获取通用资源路径
     */
    public static String getUploadPath()
    {
        return getLocalFilePath() + "/upload";
    }

    /**
     * 获取上链文件路径
     */
    public static String getUploadChainPath()
    {
        return getLocalFilePath() + "/chainFile";
    }

    /**
     * 获取头像路径
     */
    public static String getAvatarPath()
    {
        return getLocalFilePath() + "/avatar";
    }
}
